@extends('layouts.admin')

@section('title', '分配权限')

@section('content')
    <div id="pad-wrapper" class="new-user">
        <div class="row header">
            <div class="col-md-12">
                <h3>分配权限</h3>
            </div>
        </div>
        @if (count($errors) > 0)
            <div class="alert alert-danger">
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif
        <div class="row form-wrapper">
            <!-- left column -->
            <div class="col-md-9 with-sidebar">
                <form class="form-horizontal" role="form" method="post" action="/admin/roles/{{$id}}"
                      enctype="multipart/form-data">
                    <input type="hidden" name="_method" value="PUT">
                    <div class="form-group">
                        <div class="col-md-offset-2 col-md-8">
                            @foreach($permissions as $permission)
                                <label class="md-switch">
                                    <input type="checkbox" id="p{{$permission->id}}" name="permission_id[]"
                                           value="{{$permission->id}}" @if(in_array($permission->id,
                                                $permission_ids)) checked @endif>
                                    <label style="display:inline" for="p{{$permission->id}}">{{$permission->title}}</label>
                                </label>
                                <br>
                            @endforeach
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-offset-2 col-md-8">
                            <button type="submit" class="btn btn-primary">保存</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
@endsection